/*
 * Copyright 2009 Gary Brown
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 *
 * Change History:
 * 20 Mar 2009 : Initial version created by gary
 */
package org.betonthemove.ui.android;

import org.betonthemove.platform.BettingPlatform;
import org.betonthemove.platform.BettingPlatformFactory;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.*;

public class SignOut extends Activity implements OnClickListener {
 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.signout);
        
        m_logoutButton = (Button)findViewById(R.id.signout);
        m_logoutButton.setOnClickListener(this);
		
		m_cancelButton = (Button)findViewById(R.id.cancelsignout);
		m_cancelButton.setOnClickListener(this);
    }

    public void onClick(View arg0) {
    	if (arg0 == m_logoutButton) {
    		
    		BettingPlatform platform=BettingPlatformFactory.getBettingPlatform();
            
	        try {
		        platform.logout();
	        } catch(Exception e) {
	        	Log.e("SignOut", "Failed to log out", e);
	        }
    		
    		finish();
    	} else if (arg0 == m_cancelButton) {   		
            Intent intent = new Intent();
            intent.setClass(SignOut.this, EventTypeSelection.class);
            startActivity(intent);
            
            finish();
    	}
    }

	private Button m_cancelButton=null;
    private Button m_logoutButton=null;
}
